<template>
  <div class="comp_detail">
    <div class="header">
      <div class="content">
        <div class="row1">
          <div class="right">
            <div class="detailLogo">
              <img :src="compDetail.logo" alt="" />
            </div>
            <div class="content">
              <div class="detailTitle">{{ compDetail.compName }}</div>
              <div class="compType">
                <span>{{ COMPPEOPLEMAP[compDetail.peopleNum] }}</span>
                <span>·</span>
                <span>{{ COMPTYPEMAP[compDetail.compType] }}</span>
              </div>
            </div>
          </div>
          <div class="left">
            <div>
              <div class="text"> 
                {{compDetail.jobNum}}
                <span>在招职位</span>
              </div>
            </div>
            <div>
              <div class="text"> 
                 {{compDetail.userNum}}
                <span>位BOSS</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="content">
        <div class="left">
          <h2>热门职位</h2>
          <div class="hotJob">
            <div class="jobCard" @click="toDetail(p.id)" v-for="(p,i) of compDetail.hotJobs" :key="i">
              <div class="job_header">
                <h3>{{p.jobName}}</h3>
                <span><b>薪资：</b>{{p.minWage}}-{{p.maxWage}} <b>元</b></span>
              </div>
              <br>
              <br>
              <span>{{p.city}}</span>| &nbsp;&nbsp;
              <span>需要：{{p.jobNum}} 人</span>
            </div>
          </div>
          <h2>公司介绍</h2>
          <div class="compInfo">
            <h3>公司简介：</h3>
            <p>
              {{compDetail.introduction}}
            </p>
          </div>
          <div class="compInfo">
            <h3>公司官网：</h3>
            <a>
              {{compDetail.url}}
            </a>
          </div>
          <div class="compInfo">
            <h3>公司地址：</h3>
            <p>
              {{compDetail.address}}
            </p>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
import "./styles.less";
import compAPI from "../../services/comp";
import { requestWrapper } from "../../utils/request";
import { COMPTYPEMAP, COMPPEOPLEMAP } from "../../const/const";
export default {
  data() {
    return {
      compId: "",
      compDetail: {},
      COMPTYPEMAP: COMPTYPEMAP,
      COMPPEOPLEMAP: COMPPEOPLEMAP,
    };
  },
  methods: {
    toDetail(id) {
      this.$router.push({
        path: '/job_detail',
        query: {
          jobId: id
        }
      });
    },
  },
  mounted() {
    this.compId = this.$route.query.compId;
    console.log(this.compId);
    requestWrapper(compAPI.compDetail.bind(null, this.compId), {
      formatDataFn: (res) => res,
    }).then((res) => {
      console.log(res);
      this.compDetail = res.result;
    });
  },
};
</script>
